build: add ts support in core modules#62146
build: add ts support in core modules#62146marco-ippolito wants to merge 5 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
7a1197a to
f42cbf2
Compare
|
@marco-ippolito do you know what steps are needed to run and expose Rust code just like C++? |
its already done in this PR, see d9ee95f basically add the crate in the deps/crates cargo.toml, create a header file if doesnt come with the crate and add it to the node gyp |
|
Will this type strip at runtime? Or will it do it at build time? |
Build time |
|
How does this interact with the --node-builtin-modules-path flag? will it still type strip at runtime in that case? |
Yes, I tested it, it works fine. it plugs in the js2c module |
|
I'm relatively concerned about adding 1 million and 300 hundred thousand lines of code, even if they are just dependencies. Is there a solution that does not require this much? |
|
I dont think so since we are vendoring dependencies. I think the only solution is to have an automation generate them but its kinda impossible to review anyways. (The temporal PR from @legendecas had the same problem) |
|
I think the question should be is it necessary to have every swc dependencies to be included? I listed the newly added dependencies, and the followings are the biggest deps that I doubt if they are required: Additionally, crates like I think technically many of these deps can be stripped down. |
|
Can I just like delete them and see if it builds? |
fa87310 to
499c817
Compare
|
I tried to remove those crates but it seems they are all required to build. Idk if there is a way to know exactly which ones are unused or how to remove them, I'm no rust expert |
499c817 to
e9d6146
Compare
|
This is blocked by nodejs/build#4245 |
41e67c1 to
9a90466
Compare
9a90466 to
2bf33de
Compare
this seems unrelated but consistent 🫤 |
6fa7a86 to
7f79144
Compare
7f79144 to
fdb0ed9
Compare
I had she same concern in another PR I was working on. (no spoiler ;P) |
fdb0ed9 to
5c971a2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62146 +/- ##
==========================================
- Coverage 89.65% 89.65% -0.01%
==========================================
Files 676 675 -1
Lines 206543 206492 -51
Branches 39547 39532 -15
==========================================
- Hits 185184 185133 -51
+ Misses 13480 13474 -6
- Partials 7879 7885 +6 🚀 New features to boost your workflow:
|
Let's try again.
This PR allows Node.js source code to be written in TS.
This is semver major because the build now always requires rust to be installed.
This adds swc as a rust crate dependency and it's only use during build time.
Technically we could replace amaro wasm with this for type stripping but it's not the goal of this PR and in needs other considerations.
I moved an internal from .js and .ts to showcase
Also added a flag so that the transpiled code can be writte on the fs for debugging.
A lot of the addition are vendored crates sorry for the massive PR
I used AI to help me out with things I dont know (rust) so please review carefully
I had to bump the rustc from 1.82 to 1.85, obviously this cannot land if we dont update that on the CI machines nodejs/build#4245